package com.wenhao.newcode.huawei;

import java.util.Scanner;

/**
 * @author Wenhao Tong
 * @date 2021/7/15 下午10:29
 */
public class MainHJ5 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        while (scanner.hasNext()) {
            String next = scanner.next();
            int num = 0;
            for (int i = 2;i < next.length();i++) {
                int n = next.charAt(i);
                if (n >= 'A') {
                    n = n - 'A' + 10;
                } else {
                    n = n - '0';
                }
                num = (num << 4) + n;
            }
            System.out.println(num);
        }
    }
}
